stage.set_background("halfcourt")
sprite = codesters.Sprite("player4")
sprite.go_to(215, -175)
net = codesters.Sprite("basketballnet")
net.go_to(215, 175)
ball = codesters.Sprite("basketball")
x = random.randint(-100, 150)
t = codesters.Teacher()
try:
tval1 = t.get_parameters_for_function('go_to')[2]
params = t.find_function('go_to')
tval1b = params[2][1]
except:
tval1 = "DNE"
tval1b = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == ['x', '-25'], "Great Job!")
t1.add_failure(tval1 == [] or tval1 == "DNE", "Did you add a Go To command?")
t1.add_failure('x' not in tval1, "Did you change the x-coordinate to the variable x?")
t1.add_failure(tval1 == ['-100', '-50'], "Did you change the numbers in the Go To command?")
t1.add_failure('-50' in tval1, "Did you change the y-coordinate in the Go To command?")
t1.add_creative(tval1 != ['x', '-25'] and 'x' in tval1, "Creative choice!")
t2 = TestObjective()
t2.add_success('ball' in tval1b, "Great job!")
t2.add_failure('sprite' in tval1b, "Did you change the name in front of the Go To command to ball?")
t2.add_failure(tval1 == [] or tval1 == "DNE", "Did you add a Go To command?")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)